﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
        //Response.Redirect("Login.aspx ? name = "+Login1.UserName);
    }

    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        string str = "Server=HXM-PC;integrated security=SSPI; DataBase=Web_Experiment;";
        SqlConnection conn = new SqlConnection(str);
        conn.Open();
        //user属于sql里的关键字，所以会报错，一般不要用关键字作为表名，如果关zhi键字做表名用[]括起来，
        string strSql = "select * from [user] where ID='" + Login1.UserName.ToString() + "' and Password='" + Login1.Password.ToString() + "'";
        SqlCommand com = new SqlCommand(strSql, conn);
        SqlDataReader dr = com.ExecuteReader();
        if (dr.Read())
        {
            e.Authenticated = true;//通过验证 
        }
        else
        {
            e.Authenticated = false;
        }
        dr.Close();
        conn.Close();
    }

    protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
    {

    }
}